package com.ctshk.common.service.utils;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ctshk.common.utils.Assist;

/**
 * mybatis plus工具类
 * 
 * @author Qiaoxin.Hong
 *
 */
public class MybatisPlusUtils {

	/**
	 * 转换page对象
	 * @param <T>
	 * @param resultPage
	 * @param clazz
	 * @return
	 */
	public static <T> IPage<T> toPage(IPage<?> resultPage, Class<T> clazz) {
		Page<T> newResultPage = new Page<T>(resultPage.getCurrent(), resultPage.getSize(), resultPage.getTotal(), resultPage.isSearchCount());
		List<T> dtoList = Assist.toBeanList(resultPage.getRecords(), clazz);
		newResultPage.setRecords(dtoList);
		return newResultPage;
	}
}
